home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6000 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: mailhub.scitec.com.au!ramsesy
  2. From: ramsesy@rd.scitec.com.au (Ramses Youhana)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: sscanf bug??????
  5. Date: 22 Feb 1996 07:45:19 GMT
  6. Organization: SCITEC LIMITED, Sydney, Australia.
  7. Distribution: world
  8. Message-ID: <4gh6uf$i2@mailhub.scitec.com.au>
  9. References: <4fimvo$82s@fnord.dfw.net> <10FEB199622213548@erich.triumf.ca> <824160515snz@genesis.demon.co.uk>
  10. NNTP-Posting-Host: scitec7.scitec.com.au
  11. X-Newsreader: TIN [version 1.2 PL2]
  12.  
  13. Lawrence Kirby (fred@genesis.demon.co.uk) wrote:
  14. > In article <10FEB199622213548@erich.triumf.ca>
  15. >            bennett@erich.triumf.ca "P.Bennett" writes:
  16.  
  17. > >Borland says that you need to use "%ld" for long ints in both printf() and 
  18. > >scanf().  If ints and longs are the same size (as on many unix systems, I
  19. > >believe) "%d" and "%ld" can be used interchangeably, but if they are not the
  20. > >same (as on MS-DOS) then it _does_ make a difference.
  21.  
  22. > Please, *never* treat %d and %ld as interchangeable or suggest that others
  23. > could do so.
  24.  
  25. I agree.
  26.  
  27. You need the %ld for 16 bit processors or processors running in 16 bit mode.
  28. Unfortunately, your stuck with this when using a PC (using 16 bit mode).
  29. With 32 bit processors (such as a M68302 micro-controller) you don't need
  30. the %ld.  %d will do as the processor treats the number as a 32 bit entity
  31. anyway.  You have to be careful when saying that %ld and %d are interchangeable,
  32. as a compiler for a 32 bit processor (such as the M68302) may not support the
  33. "l" in the %ld format.
  34.  
  35.